import { kebabCase } from './utils'

function resolveComponent(name: string) {
  if (!name.match(/^D[A-Z]/))
  return
  const partialName = kebabCase(name.slice(1))

  return {
    name: name.slice(1),
    from: `diit-widgets/lib/${partialName}`
  }
}

export function PlusResolver() {
  return [
    {
      type: 'component',
      resolve: async (name: string) => {
        return resolveComponent(name)
      }
    }
  ]
}
